L.TileLayer.ChinaProvider = L.TileLayer.extend({

    initialize: function(type, options) {
        var providers = L.TileLayer.ChinaProvider.providers;
        var parts = type.split('.');
        var providerName = parts[0];
        var mapName = parts[1];
        var mapType = parts[2];

        var url = providers[providerName][mapName][mapType];
        options.subdomains = providers[providerName].Subdomains;
        L.TileLayer.prototype.initialize.call(this, url, options);
    }
});

L.TileLayer.ChinaProvider.providers = {
    TianDiTu_ZJ : {
        Normal_4316: {
            Map : "http://t{s}.tianditu.com/vec_c/wmts?layer=vec&style=default&tilematrixset=c&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}",
            Annotation: "http://t{s}.tianditu.com/cva_c/wmts?layer=cva&style=default&tilematrixset=c&Service=WMTS&Request=GetTile&Version=1.0.0&Format=tiles&TileMatrix={z}&TileCol={x}&TileRow={y}"
        },

        Satellite_4326: {
            Map: "http://srv{s}.zjditu.cn/ZJDOM_2D/wmts?service=WMTS&request=GetTile&version=1.0.0&style=default&format=image/jpgpng&layer=imgmap&TileMatrixSet=default028mm&TileMatrix={z}&TileCol={x}&TileRow={y}",
            Annotation: "http://srv{s}.zjditu.cn/ZJDOMANNO_2D/wmts?service=WMTS&request=GetTile&version=1.0.0&style=default&format=image/jpgpng&layer=TDT_ZJIMGANNO&TileMatrixSet=default028mm&TileMatrix={z}&TileCol={x}&TileRow={y}",
        },
        Subdomains: ['0', '1', '2', '3', '4', '5', '6', '7']
    },

    // //天地图_浙江金华永康
    // TianDiTu_ZJJHYK:{
    //     Normal_4326: {
    //         Map : "http://srv.jhmap.gov.cn/ykemap/service/WMTS?Service=WMTS&VERSION=1.0.0&Request=GetTile&Layer=YKEMAP&Format=image/png&TileMatrixSet=TileMatrixSet0&TileMatrix={z}&Style=default&TileRow={y}&TileCol={x}",
    //         Annotation: "http://srv.jhmap.gov.cn/ykemapanno/service/WMTS?Service=WMTS&VERSION=1.0.0&Request=GetTile&Layer=YKEMAPANNO&Format=image/png&TileMatrixSet=TileMatrixSet0&TileMatrix={z}&Style=default&TileRow={y}&TileCol={x}"
    //     },
    //
    //     Satellite_4326: {
    //         Map: "http://srv.jhmap.gov.cn/YKIMG/service/WMTS?Service=WMTS&VERSION=1.0.0&Request=GetTile&Layer=YKIMG&Format=image/png&TileMatrixSet=TileMatrixSet0&TileMatrix={z}&Style=default&TileRow={y}&TileCol={x}",
    //         Annotation: "http://srv.jhmap.gov.cn/YKIMGANNO/service/WMTS?Service=WMTS&VERSION=1.0.0&Request=GetTile&Layer=YKIMGANNO&Format=image/png&TileMatrixSet=TileMatrixSet0&TileMatrix={z}&Style=default&TileRow={y}&TileCol={x}"
    //     },
    //     Subdomains: []
    // },

    //天地图_浙江金华永康
    TianDiTu_ZJJH:{
        Normal_4326: {
            Map : "http://srv0.zjditu.cn/ZJEMAP_2D/wmts?Service=WMTS&VERSION=1.0.0&Request=GetTile&Layer=TDT_ZJEMAP&Format=image/png&TileMatrixSet=TileMatrixSet0&TileMatrix={z}&Style=default&TileRow={y}&TileCol={x}",
            Annotation: "http://srv3.zjditu.cn/ZJEMAPANNO_2D/wmts?Service=WMTS&VERSION=1.0.0&Request=GetTile&Layer=TDT_ZJEMAPANNO&Format=image/png&TileMatrixSet=TileMatrixSet0&TileMatrix={z}&Style=default&TileRow={y}&TileCol={x}"
        },

        Satellite_4326: {
            Map: "http://srv2.zjditu.cn/ZJDOM_2D/wmts?Service=WMTS&VERSION=1.0.0&Request=GetTile&Layer=TDT_ZJIMGANNO&Format=image/png&TileMatrixSet=TileMatrixSet0&TileMatrix={z}&Style=default&TileRow={y}&TileCol={x}",
            Annotation: "http://srv0.zjditu.cn/ZJDOMANNO_2D/wmts?Service=WMTS&VERSION=1.0.0&Request=GetTile&Layer=YKIMGANNO&Format=image/png&TileMatrixSet=TileMatrixSet0&TileMatrix={z}&Style=default&TileRow={y}&TileCol={x}"
        },
        Subdomains: ['0', '1', '2', '3', '4', '5', '6', '7']
    },

};

L.tileLayer.chinaProvider = function(type, options) {
    return new L.TileLayer.ChinaProvider(type, options);
};
